package eerbaar.v2.graphics.rect;


/**
 * Aligns the opposite sides of the cursor and the anchor.
 * 
 * Useful if the cursor is OUSIDE the anchor.
 */
public class RectAlignOpposite {

    public static Rectangle2 moveToBottomSide(Rectangle2 anchor,
            Rectangle2 cursor) {

        int y1 = anchor.y + anchor.height;
        int y2 = cursor.y;
        int dif = y2 - y1;
        return RectMove.moveUp(cursor, dif);
    }

    public static Rectangle2 moveToLeftSide(Rectangle2 anchor, Rectangle2 cursor) {

        int x1 = anchor.x;
        int x2 = cursor.x + cursor.width;
        int dif = x2 - x1;
        return RectMove.moveLeft(cursor, dif);
    }

    public static Rectangle2 moveToRightSide(Rectangle2 anchor,
            Rectangle2 cursor) {

        int x1 = anchor.x + anchor.width;
        int x2 = cursor.x;
        int dif = x2 - x1;
        return RectMove.moveLeft(cursor, dif);
    }

    public static Rectangle2 moveToTopSide(Rectangle2 anchor, Rectangle2 cursor) {

        int y1 = anchor.y;
        int y2 = cursor.y + cursor.height;
        int dif = y2 - y1;
        return RectMove.moveUp(cursor, dif);
    }

}
